package org.springframework.validation;

import java.util.List;

import javax.servlet.jsp.el.VariableResolver;

import org.springframework.validation.rules.ValidationRule;
import org.springframework.validation.util.MvcVariableResolver;
import org.springframework.validation.util.RequestUtils;

public class MvcValidationManager extends ValidationManager {
	
	protected List<ValidationRule> getContextRules(Object model) {
		String requestString = RequestUtils.removeLeadingAndTrailingSlashes(
			RequestUtils.getRequest().getServletPath());
		List<ValidationRule> contextRules = 
			rulesContainer.getContextRules(model.getClass(), requestString);
		return contextRules;
	}

	protected VariableResolver getVariableResolver(Object model) {
		return new MvcVariableResolver(RequestUtils.getRequest(), model);
	}
}
